<?php

namespace app\index\controller;

use app\index\model\TripCateModel;
use app\index\model\TripModel;
use app\index\validate\IDMustBePostiveInt;
use app\lib\exception\TripMissException;
use think\Controller;

class Trip extends Controller
{
    //旅程首页
    public function trip($id)
    {
//        (new IDMustBePostiveInt())->goCheck();
        $trip = new TripModel();
        $tripInfo = $trip->getTripByWhere($id);
//        if (!$tripInfo) {
//            throw new TripMissException();
//        }

        $this->assign('tripInfo', $tripInfo); //当前页
        return $this->fetch();
    }

    //旅程详情
    public function trip_detail($id)
    {
        $trip = new TripModel();
        $tripDetailInfo = $trip->getTripDetailInfo($id);
        $this->assign('tripDetailInfo', $tripDetailInfo);
        return $this->fetch();
    }

    //价格列表
    public function trip_price($id)
    {
        $this->assign('id', $id); //id
        return $this->fetch();
    }

    //获取价格列表
    public function getOneTripPrice()
    {
        $id = input('post.id');

        $cate = new TripModel();
        $tripPerice = $cate->getOneTripPrice($id);
        $tripPerice = $tripPerice['price_content'];
        return $tripPerice;
    }

    //返回订单信息
    public function trip_order()
    {
        return $this->fetch();
    }
}
